package com.fr.report.web;

import com.fr.base.xml.XMLObject;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import java.io.Serializable;

public abstract class Location
  implements Serializable, Cloneable
{
  public static Location createTopEmbedLocation()
  {
    return new Embed(1);
  }

  public static Location createBottomEmbedLocation()
  {
    return new Embed(3);
  }

  public static Location createEmbedLocation(int paramInt)
  {
    return new Embed(paramInt);
  }

  public static Location createFloatLocation(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
  {
    return new Float(paramInt1, paramInt2, paramInt3, paramInt4);
  }

  public static void writeXML(Location paramLocation, XMLPrintWriter paramXMLPrintWriter)
  {
    if (paramLocation != null)
    {
      paramXMLPrintWriter.startTAG("Location");
      if (paramLocation instanceof Embed)
        paramXMLPrintWriter.startTAG("Embed").attr("position", ((Embed)paramLocation).getPosition()).end();
      else if (paramLocation instanceof Float)
        paramXMLPrintWriter.startTAG("Float").attr("left", ((Float)paramLocation).getLeft()).attr("right", ((Float)paramLocation).getRight()).attr("top", ((Float)paramLocation).getTop()).attr("bottom", ((Float)paramLocation).getBottom()).end();
      paramXMLPrintWriter.end();
    }
  }

  public static Location readXML(XMLableReader paramXMLableReader)
  {
    1 local1;
    paramXMLableReader.readXMLObject(local1 = new XMLObject(null)
    {
      public void readXML(XMLableReader paramXMLableReader)
      {
        if (paramXMLableReader.isChildNode())
        {
          String str1;
          String str2 = paramXMLableReader.getTagName();
          if ("Embed".equals(str2))
          {
            if ((str1 = paramXMLableReader.getAttr("position")) != null)
              this.obj = Location.createEmbedLocation(Integer.parseInt(str1));
          }
          else if ("Float".equals(str2))
          {
            int i = -1;
            int j = -1;
            int k = -1;
            int l = -1;
            if ((str1 = paramXMLableReader.getAttr("left")) != null)
              i = Integer.parseInt(str1);
            if ((str1 = paramXMLableReader.getAttr("right")) != null)
              j = Integer.parseInt(str1);
            if ((str1 = paramXMLableReader.getAttr("top")) != null)
              k = Integer.parseInt(str1);
            if ((str1 = paramXMLableReader.getAttr("bottom")) != null)
              l = Integer.parseInt(str1);
            this.obj = Location.createFloatLocation(k, l, i, j);
          }
        }
      }
    });
    return ((Location)local1.getObject());
  }

  public static final class Float extends Location
  {
    private int top;
    private int bottom;
    private int left;
    private int right;

    public Float()
    {
    }

    public Float(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
    {
      this.top = paramInt1;
      this.bottom = paramInt2;
      this.left = paramInt3;
      this.right = paramInt4;
    }

    public int getTop()
    {
      return this.top;
    }

    public void setTop(int paramInt)
    {
      this.top = paramInt;
    }

    public int getBottom()
    {
      return this.bottom;
    }

    public void setBottom(int paramInt)
    {
      this.bottom = paramInt;
    }

    public int getLeft()
    {
      return this.left;
    }

    public void setLeft(int paramInt)
    {
      this.left = paramInt;
    }

    public int getRight()
    {
      return this.right;
    }

    public void setRight(int paramInt)
    {
      this.right = paramInt;
    }
  }

  public static final class Embed extends Location
  {
    private int position = 1;

    public Embed()
    {
    }

    public Embed(int paramInt)
    {
      this.position = ((paramInt == 1) ? 1 : 3);
    }

    public int getPosition()
    {
      return this.position;
    }

    public void setPosition(int paramInt)
    {
      this.position = paramInt;
    }
  }
}